// 食物类
class Food {
  element: HTMLElement;
  constructor() {
    this.element = document.getElementById('food')!;
  }
  get X(): number {
    return this.element.offsetLeft;
  }
  get Y(): number {
    return this.element.offsetTop;
  }
  // 生成食物 随机位置
  generate(): void {
    this.element.style.left = Math.round(Math.random() * 29) * 10 + 'px';
    this.element.style.top = Math.round(Math.random() * 29) * 10 + 'px';
  }
}

export default Food;